package org.apache.myfaces.blank.tm.jdk18;

import java.util.Arrays;
import java.util.stream.IntStream;

/**
 * @author JsD
 * @ClassName LongStream.java
 * @Description
 * @createTime 2021年06月04日 09:46:00
 */
public class LongStream {
    public static void main(String[] args) {
        java.util.stream.LongStream longStream = java.util.stream.LongStream.rangeClosed(10L, 20L);
        longStream.forEach(System.out::println);


        int [] ints={1,5,9,2,5,63,4,8,81,83,88};
        System.out.println("________分割线① rangeClosed 使用_________");
        IntStream.rangeClosed(0,5).forEach(System.out::println);


        System.out.println("________分割线② range 使用_________");
        IntStream.range(0,5).forEach(System.out::println);


        System.out.println("________分割线② sum 使用_________");
        int sum = IntStream.rangeClosed(0, 5).sum();
        System.out.println(sum);


        System.out.println("________分割线② sorted 使用_________");
        IntStream.of(ints).sorted().forEach(System.out::println);


        System.out.println("________分割线③ foreach 使用_________");
        Arrays.stream(ints).forEach(x ->System.out.println(x+2));
        Arrays.stream(ints).forEach(System.out::println);

        System.out.println("________分割线④ filter 对数据过滤 使用_________");
        String[] arrs = {"hello","world","welcome","meet","you","aaa"};
        Arrays.stream(arrs).filter(s -> s.startsWith("h")).forEach(System.out::println);
    }
}
